/**
 ************************************************************************************************************
 * 
 ************************************************************************************************************
 * @file RBRenderTargetGroup.h
 ************************************************************************************************************/

#ifndef __RBRENDERTARGETGROUP__H__
#define __RBRENDERTARGETGROUP__H__

#ifdef  HEADER_ONCE
#pragma HEADER_ONCE
#endif

#ifdef  HEADER_MSG
#pragma HEADER_MSG(RBRenderTargetGroup.h)
#endif

/************************************************************************************************************
 * Includes
 ************************************************************************************************************/
#include "RBRefObject.h"
#include "RBPixelBuffer.h"
#include "RBTexture.h"

/************************************************************************************************************
 * Forward declarations
 ************************************************************************************************************/

/************************************************************************************************************
 * Class
 ************************************************************************************************************/

class RBRenderTargetGroup : public RBRefObject
{
    RBDeclareRTTI(RBRenderTargetGroup, RBRefObject);

    friend class RBRenderer;

public:

    static const uint32           ms_maxColorBuffer = 4;

    static RBRenderTargetGroup*   Create              (uint32 uiWidth, uint32 uiHeight, RBPixelFormat eColorFormat, RBPixelFormat eDSFormat,
                                                       bool bColorIsTexture = true, bool bDSIsTexture = false, uint32 uiMipCount = 1, uint32 uiMSAA = 0, uint32 uiColorBufferCount = 1);
    
    static RBRenderTargetGroup*   Create              (RBTexture* pColorBuffer  = 0, RBTexture* pDSBuffer = 0, 
                                                       RBTexture* pColorBuffer1 = 0, RBTexture* pColorBuffer2 = 0, RBTexture* pColorBuffer3 = 0);

    static RBRenderTargetGroup*   Create              (RBRenderTargetView* pColorView0  = 0, RBDepthStencilView* pDSView = 0, 
                                                       RBRenderTargetView* pColorView1 = 0, RBRenderTargetView* pColorView2 = 0, RBRenderTargetView* pColorView3 = 0);

    // Warning: may be NULL
    RBRenderTargetView*           GetRenderTargetView (uint32 uiBuffer = 0) const;

    const RBRenderTargetView*const* GetRenderTargetViews () const;
    RBDepthStencilView*           GetDepthStencilView () const;

    uint32                        GetBufferCount      ();

    void                          Resize              (uint32 uiWidth, uint32 uiHeight);

                                 ~RBRenderTargetGroup ();
protected:
                                  RBRenderTargetGroup (const std::vector<RBRenderTargetView*>& vBuffers, RBDepthStencilView* pDSBuffer, bool bOwnsData);


private:
    std::vector<RBRenderTargetView*> m_aColorBuffers;   // The pixel buffers which we render to: may or may not be MSAA
    RBDepthStencilView*           m_pDSBuffer;         // The Depth Stencil Buffer
    bool                            m_bOwnsData;
};

RBDeclareSmartPointer(RBRenderTargetGroup);

/************************************************************************************************************/

#endif // __RBRENDERTARGETGROUP__H__
